import * as THREE from 'three';
import { loadGltf } from '../three-utils';

/**
 * 加载河流
 * @returns
 */
export const loadRiver = (skyMap: THREE.Texture) => {
  return loadGltf({
    modelPath: '/model/rivier/model.glb',
  }).then((gltf) => {
    const group = gltf.scene;
    const children = group.children;
    const mesh = children[0] as THREE.Mesh;
    const material = mesh.material as THREE.MeshPhysicalMaterial;
    material.side = THREE.FrontSide;
    material.transparent = true;
    material.opacity = 0.2;
    material.envMap = skyMap;
    material.envMapIntensity = 10;
    // material.normalMap = new THREE.TextureLoader().load('/model/rivier/Water_1_M_Normal.jpg');
    children.forEach((item) => {
      item.material = material;
    });

    return group;
  });
};
